<?php
declare (strict_types=1);

namespace app\common\model;

class ProductCate extends Base
{
    protected $name = 'product_cate';

    public function children()
    {
        return $this->hasMany(ProductCate::class, 'pid')
            ->field('id,pid,title')->with('children');
    }

    public static function getCate($id = 0)
    {
        return parent::where(['pid' => $id,'status' => 1])
            ->field("id,icon,title")->order('sort')->select();
    }

}
